<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta charset="UTF-8">
	<title>新增商品</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />

 <!-- 新模板 -->
<link rel="shortcut icon" href="<c:url value='/template/new_muban/images/favicon.ico'/>" type="image/x-icon"/>

<!-- 最新导入 -->
<script type="text/javascript" src="<c:url value='/template/new_muban/js/jquery-min-1.7.js'/>"></script>
<link rel="stylesheet" href="<c:url value='/template/new_muban/css/font.css'/>">
<link rel="stylesheet" href="<c:url value='/template/new_muban/css/xadmin.css'/>">   
<script src="<c:url value='/template/new_muban/lib/layui/layui.js'/>" charset="utf-8"></script> 
<script type="text/javascript" src="<c:url value='/template/new_muban/js/xadmin.js'/>"></script>
 <!-- 富文本编辑器 -->
<script type="text/javascript" charset="utf-8" src="<c:url value='/ue/ueditor.config.js'/>"></script>
<script type="text/javascript" charset="utf-8" src="<c:url value='/ue/ueditor.all.js'/>"> </script>

<style type="text/css">
	/*圆形头像  */
	/* #divcss5{ margin:10px auto}  */
	#divcss5 img{ border-radius:50%} 
	.x-so input.layui-input {
    	width: 150px;
	}
</style>
<style>
.layui-upload-img {
	width: 92px;
	height: 92px;
	margin: 0 10px 10px 0;
}
</style>
<style type="text/css">
.uploader-list {
	margin-left: -15px;
}

.uploader-list .info {
	position: relative;
	margin-top: -25px;
	background-color: black;
	color: white;
	filter: alpha(Opacity = 80);
	-moz-opacity: 0.5;
	opacity: 0.5;
	width: 100px;
	height: 25px;
	text-align: center;
	display: none;
}

.uploader-list .handle {
	position: relative;
	background-color: black;
	color: white;
	filter: alpha(Opacity = 80);
	-moz-opacity: 0.5;
	opacity: 0.5;
	width: 100px;
	text-align: right;
	height: 18px;
	margin-bottom: -18px;
	display: none;
}

.uploader-list .handle i {
	margin-right: 5px;
}

.uploader-list .handle i:hover {
	cursor: pointer;
}

.uploader-list .file-iteme {
	margin: 12px 0 0 15px;
	padding: 1px;
	float: left;
}
</style>


</head>
<body>
   
     <div class="x-body" id="x-img">
     
     
  <div class="layui-fluid">
   <blockquote class="layui-elem-quote">
  当前位置:新增商品,点击查看
  <a class="layui-btn layui-btn-normal" href="<c:url value='/selectSupplyAllGoods.do'/>" >商品管理</a>
</blockquote>  
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                    <div class="layui-card-body">
                     <form class="layui-form"> 
 

 
	<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
	  <ul class="layui-tab-title">
	  <li  class="layui-this">基本信息</li>
	    <li>佣金与库存</li>
	    <li>商品详情</li>
	
	  </ul>
	  <div class="layui-tab-content" >
	  <div class="layui-tab-item layui-show">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>基本信息</legend>
</fieldset>	  
	  	<div class="layui-form-item">
	              <label for="username" class="layui-form-label">
	                  <span class="x-red">*</span>商品名称
	              </label>
	              <div class="layui-input-block">
	                  <input type="text" id="goodsname" name="goodsname" value="${goodsDetails.goodsname}" placeholder="请输入商品名称" maxlength="32" required="" lay-verify="required"
	                  autocomplete="off" class="layui-input">
	              </div>
	          </div>
	          
	          
			<div class="layui-form-item">
              <label for="L_email" class="layui-form-label">
                  <span class="x-red">*</span>所属分类
              </label>
              <div class="layui-input-block">
              <!-- checked="checked" -->
                <c:forEach	items="${allGoodsCategory}" var="category">
                    <input type="checkbox"  name="sc_id" value="${category.sc_id}" title="${category.sc_name}" lay-skin="primary" 
                    	<c:forEach	items="${supplyGoodsCategoryByGoods}" var="category_goods">
                    		<c:if test="${category.sc_id == category_goods.sc_id}">checked="checked"</c:if>
                    	</c:forEach>
                    
                    >
              		<div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>${category.sc_name}</span><i class="layui-icon layui-icon-ok"></i></div>
              		
              	</c:forEach>
              </div>
             
          </div>
          
      <%--     <div class="layui-form-item">
              <label for="L_email" class="layui-form-label">
                  <span class="x-red">*</span>类型
              </label>
              <div class="layui-input-inline">
             		<select name="type" id="type" lay-filter="required">
		       			<option value="virtual"  <c:if test="${goodsDetails.type == 'virtual'}">selected="selected"</c:if>>核销商品</option>
		       		 	<option value="normal" <c:if test="${goodsDetails.type == 'normal'}">selected="selected"</c:if>>普通商品</option> 
		        </select>  
              </div>
             
          </div> --%>
		<div class="layui-form-item">
        <label for="username" class="layui-form-label">
                <span class="x-red">*</span>原价
            </label>
            <div class="layui-input-inline">
                <input type="text" id="productprice" name="productprice"  value="${goodsDetails.productprice}"  placeholder="请输入商品原价" required="" lay-verify="required"
                autocomplete="off" class="layui-input" onkeyup="clearNoNum(this);">
            </div>
        </div>	 
		<div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>购买价格
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="price" name="price"  value="${goodsDetails.price}" placeholder="请输入购买价格" required="" lay-verify="required"
                  autocomplete="off" class="layui-input" onkeyup="clearNoNum(this);">
              </div>
          </div>
<%-- <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>拼团设置</legend>
</fieldset> 
        <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>拼团价格
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="pinprice" name="pinprice" value="${goodsDetails.pinprice}" placeholder="请输入拼团价格" required="" lay-verify="required"
                  autocomplete="off" class="layui-input" onkeyup="clearNoNum(this);">
              </div>
          </div>
          <div class="layui-form-item">
	              <label for="username" class="layui-form-label">
	                  <span class="x-red">*</span>最低成团人数
	              </label>
	              <div class="layui-input-inline">
	                  <input type="text" id="pin_count" name="pin_count" value="${goodsDetails.pin_count}" value="0" placeholder="请输入最低成团人数" maxlength="4" required="" lay-verify="required"
	                  autocomplete="off" class="layui-input"  onkeyup="this.value=this.value.replace(/\D/g,'');">
	              </div>
	          </div> 
	       <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>拼团时间
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="pin_hour" name="pin_hour" value="${goodsDetails.pin_hour}"  placeholder="请输入拼团时间,小时为单位" required="" lay-verify="required"
                  autocomplete="off" class="layui-input" onkeyup="clearNoNum(this);">
              </div>
          </div>       --%>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>时间设置</legend>
</fieldset>	          
          <div class="layui-form-item" >
		    <label for="L_username" class="layui-form-label"><span class="x-red">*</span>活动开始/结束日期</label>
		    <div class="layui-input-block">
		    	<input type="text" name="hd_date"  class="layui-input" id="hd_date" 
		    		value ="${goodsDetails.begin_time} - ${goodsDetails.end_time}"
		    		 readonly="readonly"  lay-verify="required">
					<input type="hidden" class="layui-input" id="starttime"  name="starttime" value="${goodsDetails.begin_time}"> <!-- &nbsp;&nbsp;&nbsp;&nbsp; -->
					<input type="hidden" class="layui-input" id="endtime" name="endtime" value="${goodsDetails.end_time}"> <!-- &nbsp;&nbsp;&nbsp;&nbsp; -->
		    </div> 
		  </div> 
		   <div class="layui-form-item" >
		    <label for="L_username" class="layui-form-label"><span class="x-red">*</span>核销开始/结束日期</label>
		    <div class="layui-input-block">
		    	<input type="text" name="hx_date" class="layui-input" id="hx_date" 
		    	value ="${goodsDetails.hx_start_time} - ${goodsDetails.hx_end_time}"
		    	 readonly="readonly"  lay-verify="required">
					<input type="hidden" class="layui-input" id="hx_starttime"  name="starttime" value="${goodsDetails.hx_start_time}"> <!-- &nbsp;&nbsp;&nbsp;&nbsp; -->
					<input type="hidden" class="layui-input" id="hx_endtime" name="endtime" value="${goodsDetails.hx_end_time}"> <!-- &nbsp;&nbsp;&nbsp;&nbsp; -->
		    </div> 
		  </div>    
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>图片设置</legend>
</fieldset>	   
	<div class="layui-form-item layui-form-text">
			<label for="desc" class="layui-form-label"> <span
				class="x-red">*</span>外部图片
			</label>
			<div class="layui-input-inline">
			<input type="hidden" id="big_img" lay-verify="required" value="${goodsDetails.big_img}">
				<button type="button" class="layui-btn" id="big_img_btn">上传图片</button>
				<div class="layui-upload-list">
					<img class="layui-upload-img" id="big_img_demo" src="${goodsDetails.big_img}">
					<p id="big_img_demoText"></p>
				</div>
				
			</div>
		</div>
<div class="layui-form-item layui-form-text">
			<label for="desc" class="layui-form-label"> <span
				class="x-red">*</span>海报图片
			</label>
			<div class="layui-input-inline">
				<input type="hidden" id="goods_share_image" lay-verify="required" value="${goodsDetails.goods_share_image}">
				<button type="button" class="layui-btn" id="goods_share_image_btn">上传图片</button>
				<div class="layui-upload-list">
					<img class="layui-upload-img" id="goods_share_image_demo" src="${goodsDetails.goods_share_image}">
					<p id="goods_share_image_demoText"></p>
				</div>
			</div>
			 <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>海报推荐尺寸 : 1045 * 1503 
              </div>	
		</div>
 <div class="layui-form-item layui-form-text">
			<label for="desc" class="layui-form-label"> <span
				class="x-red">*</span>分享图片
			</label>
			<div class="layui-input-inline">
				<input type="hidden" id="wepro_qrcode_image" lay-verify="required" value="${goodsDetails.wepro_qrcode_image}">
				<button type="button" class="layui-btn" id="wepro_qrcode_image_btn">上传图片</button>
				<div class="layui-upload-list">
					<img class="layui-upload-img" id="wepro_qrcode_image_demo" src="${goodsDetails.wepro_qrcode_image}">
					<p id="wepro_qrcode_image_demoText"></p>
				</div>
			</div>
			<div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>分享推荐尺寸 : 750 * 800 
              </div>	
		</div>	 	
		
	<div class="layui-form-item layui-form-text">
			<label for="desc" class="layui-form-label"> 
				<span class="x-red">*</span>轮播图
			</label>
			<div class="layui-input-block">
				<div class="layui-upload">
					<button type="button" class="layui-btn" id="test2">多图上传</button>
					<blockquote class="layui-elem-quote layui-quote-nm"
						style="margin-top: 10px; width: 88%">
						预览图：
						<div class="layui-upload-list uploader-list" style="overflow: auto;"
							id="uploader-list">
							 <c:forTokens items="${image_str}" delims="," var="banner">  
						         
							 <div id="" class="file-iteme">
							 <div class="handle"><i class="layui-icon layui-icon-delete"></i></div>
							 	<img style="width: 100px;height: 100px;" src="<c:out value="${banner}"/>">
									<div class="info"></div>
							</div>
						    </c:forTokens> 
	                    
							
						</div>
					</blockquote>
				</div>
			
			</div>
		</div>



       
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>其他信息</legend>
</fieldset>	          
          <div class="layui-form-item">
	              <label for="username" class="layui-form-label">
	                  <span class="x-red">*</span>一句话简介
	              </label>
	              <div class="layui-input-block">
	                  <input type="text" id="subtitle" name="subtitle" value="${goodsDetails.subtitle}" placeholder="请输入一句话简介" maxlength="32" required="" lay-verify="required"
	                  autocomplete="off" class="layui-input">
	              </div>
	          </div>
		
		<div class="layui-form-item">
	              <label for="username" class="layui-form-label">
	                  <span class="x-red">*</span>排序
	              </label>
	              <div class="layui-input-inline">
	                  <input type="text" id="index_sort" name="index_sort" value="${goodsDetails.index_sort}" placeholder="请输入排序值" maxlength="4" required="" lay-verify="required"
	                  autocomplete="off" class="layui-input"  onkeyup="this.value=this.value.replace(/\D/g,'');">
	              </div>
	          </div>

		</div>
		

<div class="layui-tab-item">
			<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>库存设置</legend>
</fieldset>

          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>设置销量
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="sales" name="sales" value="${goodsDetails.sales}"  placeholder="请输入起始销量" required="" lay-verify="required"
                  autocomplete="off" class="layui-input"  onkeyup="this.value=this.value.replace(/\D/g,'');">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>小程序端显示销量,不影响实际销量
              </div>
          </div>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>库存量
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="total" name="total" value="${goodsDetails.total}"  placeholder="请输入商品库存" required="" lay-verify="required"
                  autocomplete="off" class="layui-input"  onkeyup="this.value=this.value.replace(/\D/g,'');">
              </div>
          </div>
         <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>佣金设置</legend>
</fieldset>	  


<div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>分享佣金
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="yj_money" name="yj_money" value="${goodsDetails.yj_money}" placeholder="请输入分享佣金" required="" lay-verify="required"
                  autocomplete="off" class="layui-input" onkeyup="clearNoNum(this);">
              </div>
                <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>根据用户等级分佣,用户成为分销商后,可自购返佣
              </div>
          </div>
<div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>推荐佣金
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="commission1_pay" name="commission1_pay"  value="${goodsDetails.commission1_pay}" placeholder="请输入推荐佣金" required="" lay-verify="required"
                  autocomplete="off" class="layui-input" onkeyup="clearNoNum(this);">
              </div>
          </div>


	  <div class="layui-form-item">
              <label for="username" class="layui-form-label" >
              <span class="x-red">*</span>  团佣
              </label>
              <div class="layui-input-block" id="spec_spec" style="width: 70%;">
					<input type="hidden" id="goods_spec_spec" name="goods_spec_spec" value="${goodsDetails.community_head_commission_modify}"/>
					<table id="table1" width="100%" class="layui-table" lay-size="sm">
			        	<thead>
				        	<tr> 
				        		<th>
					        		等级
					        	</th>
					        	<th>
					        		佣金
					        	</th>
					    	
					            <!-- <th>
					           	 	操作
					            </th> -->
				            </tr>
			            </thead>
			               	<tbody class="tbody1">
			               		<tr>
			               				<td>
			               					默认等级 --> head_level_0<input type="hidden" class="layui-input datetime"  readonly="readonly" placeholder="请输入等级名称" value="head_level_0" />
			               				</td>
			               				<td>
			               					<input type="text" class="layui-input datetime" value="${yjMap.head_level_0}" lay-verify="required" onkeyup="clearNoNum(this);" placeholder="请输入佣金" />
			               				</td>
			               				
			               				<!-- <td style="text-align:center;">
			               					<input type="button" onclick="delThis(this)" class="layui-btn layui-btn-sm" value="删除此行"/>
			               				</td> -->
			               			</tr>
			               		<c:forEach items="${allHeadLevel}" var="headLevl" varStatus="sm">
			               			<tr>
			               				<td>
			               					${headLevl.levelname} --> head_level_${sm.index+1}<input type="hidden" class="layui-input datetime" readonly="readonly" placeholder="请输入等级名称" value="head_level_${sm.index+1}" />
			               				</td>
			               				<td>
			               					<c:set var="page_lvel" scope="page" value="head_level_${sm.index+1}"/>
			               					
			               				<%-- 	${yjMap[page_lvel]}
			               			
    									 --%>
			               					<input type="text" class="layui-input "
			               						value="${yjMap[page_lvel]}"
			               					 lay-verify="required" placeholder="请输入佣金" onkeyup="clearNoNum(this);" />
			               				</td>
			               				 <!-- onkeyup="clearNoNum(this);" -->
			               				<!-- <td style="text-align:center;">
			               					<input type="button" onclick="delThis(this)" class="layui-btn layui-btn-sm" value="删除此行"/>
			               				</td> -->
			               			</tr>
			               				
			               		</c:forEach>
			               	</tbody>
			               	<tfoot><tr><td colspan="4" style="text-align:center;">请根据服务商的等级,分配合适的佣金<!-- <input type="button" onclick="addData(this);" class="layui-btn layui-btn-sm" value="新增"/> --></td></tr></tfoot>
			    	        </table>
              </div>
          </div>
	          
	        
		
		</div>
		
		

		
<div class="layui-tab-item">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>须知</legend>
</fieldset>	  

	<div class="layui-form-item" >
    <label for="L_username" class="layui-form-label"><span class="x-red">*</span>须知</label>
    <div class="layui-input-block">
		<script id="editor1" name="editor1" type="text/plain" style="width:100%;height:500px;">${goodsDetails.xuzhi}</script>
    </div>         		 
 </div> 
 <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>商品详情</legend>
</fieldset>	  
		<div class="layui-form-item layui-form-text">
              <label for="desc" class="layui-form-label">
          <span class="x-red">*</span>详情
              </label>
              <div class="layui-input-block" >
               	<script id="editor" type="text/plain" style="width:100%;height:500px;">${goodsDetails.content}</script>
              </div>
           </div>
		
		</div>
	  
	  </div>
	</div> 
 
 
          
          
  
          
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                 修改
              </button>
          </div>
      </form>
                    
                    
                    </div>
                    </div>
                </div>
             </div>
      </div>
                        
        
    </div>
    <script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
        //执行一个laydate实例
        laydate.render({
      	  type: 'time'
      		    ,format: 'HH:mm:ss'
          ,elem: '#end_time' //指定元素
        });
      });
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;
          
          
          
        
          //自定义验证规则
          form.verify({
            nikename: function(value){
              if(value.length < 5){
                return '昵称至少得5个字符啊';
              }
            }
            ,pass: [/(.+){6,12}$/, '密码必须6到12位']
            ,repass: function(value){
                if($('#L_pass').val()!=$('#L_repass').val()){
                    return '两次密码不一致';
                }
            }
          });

          var flag = "A";
          form.on('radio(ho_type)', function(data){
			    //console.log(data.elem); //得到radio原始DOM对象
			    console.log(data.value); //被点击的radio的value值
			     if(data.value==0){
			     	    flag = "B";
			     }
			   
			     
			}); 
          
          var ho_bx_flag = "A";
          form.on('radio(ho_bx)', function(data){
			    //console.log(data.elem); //得到radio原始DOM对象
			    console.log(data.value); //被点击的radio的value值
			     if(data.value==1){
			    	 ho_bx_flag = "B";
			     }
			   
			     
			}); 

          
          
          
          //监听提交
          form.on('submit(add)', function(data){
           
        	  //商品名称
        	  var goodsname = $("#goodsname").val();
        	  //一句话
        	  var subtitle  = $("#subtitle").val();
        	  //价格
        	  var price = $("#price").val();
        	  //原价
        	  var productprice = $("#productprice").val();
        	  //销量
        	  var sales = $("#sales").val();
        	  //类型
        	  var type = "${goodsDetails.type}";//$("#type").val()
        	  //库存
        	  var total = $("#total").val();
           
             
           
            if(total == '' || total==null){
            	total = 0;
            }
         
        	//一级分销金额
        	 var commission1_pay = $("#commission1_pay").val();
        	 var yj_money = $("#yj_money").val();
            //团佣格式化
           // var map  = {}; 		
			var aa;
				var map1={};
			$("#table1").each(function(index1,obj1){
				//console.log("table进来了");
				
				aa = $(this).children(0).children(0).children(0).children(0).val();
				//console.log("aa : "+aa);
			$($(this).find("tbody tr")).each(function(index2,obj2){
				
				var key1 = $(this).children().eq(0).children().val();
				var value1 = $(this).children().eq(1).children().val();
				if(key1 != ""){					
					map1[key1] = value1;
				}
				
			});
			//console.log("map1 : "+map1);
				//map[aa] = map1; 
		
			});
			var map2json=JSON.stringify(map1);
			
			//console.log("map2json : "+map2json);
			var community_head_commission_modify = map2json;
            
			console.log("community_head_commission_modify : "+community_head_commission_modify);
			
			
			//活动开始
			var hd_date = $("#hd_date").val();
			//核销开始
			var hx_date = $("#hx_date").val();
		
			
			if ($(".file-iteme").length < 1) {
				   layer.msg('上传图片不能少于1张!',{icon: 2,time:3000});   
					return false;
			 }
			if ($(".file-iteme").length > 5) {
				   layer.msg('上传图片不能多于5张!',{icon: 2,time:3000});   
					return false;
			 }
			
			//外部图
			var big_img = $("#big_img").val();
			//轮播图
			 var banner = images.toString();
			//海报图
			var goods_share_image = $("#goods_share_image").val();
			//分享图
			var wepro_qrcode_image = $("#wepro_qrcode_image").val();
			
			 //绑定分类
	          var checkbox_sc_id = $("input:checkbox[name='sc_id']:checked").map(function(index,elem) {
	              return $(elem).val();
	          }).get().join(',');
			 
			 if(checkbox_sc_id == "" || checkbox_sc_id == null ||checkbox_sc_id == "undefined"){
				 layer.msg('未绑定商品分类!',{icon: 2,time:3000});   
					return false;
			 }
			 
			 //活动详情
	         var content = UE.getEditor('editor').getContent();
	         if(content == "" || content == null){
	        	  layer.msg('请输入详情!',{icon: 2,time:3000});      
		      	  return false; 
	         }  
	         var xuzhi = UE.getEditor('editor1').getContent();
	         if(xuzhi == "" || xuzhi == null){
	        	  layer.msg('请输入须知!',{icon: 2,time:3000});      
		      	  return false; 
	         }  
	         
	  /*        var pinprice = $("#pinprice").val();
	         var pin_count = $("#pin_count").val();
	         
	         var pin_hour = $("#pin_hour").val(); */
	         
	         /* ,"pinprice":pinprice,"pin_count":pin_count,"pin_hour":pin_hour */
	         var goods_id = "${goodsDetails.goods_id}";
        	//return false;
        	  $.ajax({
	                type: 'POST',
	                url: "<c:url value='/updateSupplyGoods.do'/>",
			     	async : false, // 注意此处需要yi步  
		    		data: {
		 	   			"goods_id":goods_id,"goodsname":goodsname,"subtitle":subtitle,"price":price,"productprice":productprice,
		 	   		"sales":sales,"type":type,"total":total,"community_head_commission_modify":community_head_commission_modify,"commission1_pay":commission1_pay,
		 	   		"hd_date":hd_date,"hx_date":hx_date,"big_img":big_img,"banner":banner,"checkbox_sc_id":checkbox_sc_id,"content":content,
		 	   		"xuzhi":xuzhi,"goods_share_image":goods_share_image,"wepro_qrcode_image":wepro_qrcode_image,"yj_money":yj_money
		    		},
			        success: function(data){		
						if (data == 0) {
		             	   layer.msg('修改失败!',{icon: 2,time:3000});      
		                    return false;
		                } else if(data ==1)  {
		
		                	  layer.msg("修改成功", {icon: 6,time:1000},function () {
		                		  window.location.href = "<c:url value='/selectSupplyAllGoods.do'/>";
		                		  // 获得frame索引
		                          //var index = parent.layer.getFrameIndex(window.name);
		                          //alert(index);
		                          //关闭当前frame
		                          //parent.layer.close(index);
		                          //重新加载父页面
		                          //parent.location.reload();
		                      });
				           }
	             
	                }
				});
        	
            return false;
          });
          
          
        });
    </script>
     <script type="text/javascript">
//小数验证
	function clearNoNum(obj){  
     //修复第一个字符是小数点 的情况.  
     if(obj.value !=''&& obj.value.substr(0,1) == '.'){  
         obj.value="";  
     }  
     obj.value = obj.value.replace(/^0*(0\.|[1-9])/, '$1');//解决 粘贴不生效  
     obj.value = obj.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符  
     obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的       
     obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");      
     obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数       
     if(obj.value.indexOf(".")< 0 && obj.value !=""){//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额  
         if(obj.value.substr(0,1) == '0' && obj.value.length == 2){  
             obj.value= obj.value.substr(1,obj.value.length);      
         }  
     }      
 }   

 </script>       
<script type="text/javascript">

//规格数据操作
function delData(obj){
	$(obj).parent().parent().parent().parent().remove();
	//alert(index);
	index = index - 1 ;
	//alert("删除后 = "+index);
}
function delThis(obj){
	$(obj).parent().parent().remove();
	
}
</script>
   <script type="text/javascript">
      layui.use('laydate', function(){
    	  var laydate = layui.laydate;
    	  
    	  //执行一个laydate实例
    	  laydate.render({
    	    elem: '#hd_date' //指定元素  
    	   ,range: true
    	   ,type: 'datetime'
    	  });
    	  laydate.render({
      	    //指定元素
      	   	elem: '#hx_date'
      	   ,range: true
      	   ,type: 'datetime'
      	  });    
    	  
    	  
  		});
      
      </script>
      
<script type="text/javascript">
//多图容器 【注册全局变量】
//var images = ["${image_str}"];
var sss = "${image_str}";
//var stringResult = 
var images = sss.split(',');
//var images = [];
layui.use('upload', function(){
	  var $ = layui.jquery
	  ,upload = layui.upload;

	//多图片上传
	var uploadInst = upload.render({
		elem: '#test2'
            ,url: "<c:url value='/uploadToQiNiu.do'/>"
            ,multiple: true
            ,before: function(obj){
                layer.msg('图片上传中...', {
                    icon: 16,
                    shade: 0.01,
                    time: 0
                })
            }
            ,done: function(res){
            	//console.log(res);
            	//console.log(res.file_url);
                layer.close(layer.msg());//关闭上传提示窗口
                var title = res.file_url;
                var i1 = title.lastIndexOf("_"); //3
                title = title.substr(i1 +1);
                
                if ($(".file-iteme").length >=5) {
            		return layer.msg('上传图片不能多于5张！');
				  }else{
					  
	                //上传完毕
	                $('#uploader-list').append(
	                    '<div id="" class="file-iteme">' +
	                    '<div class="handle"><i class="layui-icon layui-icon-delete"></i></div>' +
	                    '<img style="width: 100px;height: 100px;" src='+ res.file_url +'>' +
	                    '<div class="info">' + title + '</div>' +
	                    '</div>'
	                    
	                );
	                  //追加图片成功追加文件名至图片容器
	                    images.push(res.file_url);
				 }
                
            }
	});
	
	
	
	
	
	
	/* 单图  */
	 upload.render({
		    elem: '#big_img_btn'
	 	   ,url: '<%=request.getContextPath()%>/uploadToQiNiu.do'
	 	   ,auto:true
	 	,size: 1024//限制文件大小，单位 KB
	 	   ,exts: 'jpg|png'
	 	   ,xhr:xhrOnProgress
	 	   ,progress:function(value){//上传进度回调 value进度值
	 	     console.log(value);
	 	     element.progress('demo', value+'%')//设置页面进度条
	 	    }
	 	   //,bindAction: '#test-upload-change-action'
	 	   ,before: function(obj){
	 	   //返回的参数item，即为当前的input DOM对象
	 	     layer.load(); //上传loading
	 	       console.log('文件上传中');
	 	 
	 	     //预读本地文件示例，不支持ie8
	 	     obj.preview(function(index, file, result){
	 	       $('#big_img_demo').attr('src', result); //图片链接（base64）
	 	     });
	 	 
	 	   }
	 	   ,done: function(res){
	 	     console.log("返回码 : "+res.code);
	 		
	  		 //如果上传失败
	 	      if(res.code != 200){
	 	        return layer.msg('上传失败');
	 	      }
	 	     layer.closeAll();
	 	     layer.msg("上传成功");
	 	      //上传成功
	 	      $("#big_img").val(res.file_url);
	 		
	 	   },error: function(){
		      //演示失败状态，并实现重传
		      var demoText = $('#big_img_demoText');
		      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
		      demoText.find('.demo-reload').on('click', function(){
		        uploadInst.upload();
		      });
		    }

	});
	
	
	 /* 海报单图  */
	 upload.render({
		    elem: '#goods_share_image_btn'
	 	   ,url: '<%=request.getContextPath()%>/uploadToQiNiu.do'
	 	   ,auto:true
	 	,size: 1024//限制文件大小，单位 KB
	 	   ,exts: 'jpg|png'
	 	   ,xhr:xhrOnProgress
	 	   ,progress:function(value){//上传进度回调 value进度值
	 	     console.log(value);
	 	     element.progress('demo', value+'%')//设置页面进度条
	 	    }
	 	   //,bindAction: '#test-upload-change-action'
	 	   ,before: function(obj){
	 	   //返回的参数item，即为当前的input DOM对象
	 	     layer.load(); //上传loading
	 	       console.log('文件上传中');
	 	 
	 	     //预读本地文件示例，不支持ie8
	 	     obj.preview(function(index, file, result){
	 	       $('#goods_share_image_demo').attr('src', result); //图片链接（base64）
	 	     });
	 	 
	 	   }
	 	   ,done: function(res){
	 	     console.log("返回码 : "+res.code);
	 		
	  		 //如果上传失败
	 	      if(res.code != 200){
	 	        return layer.msg('上传失败');
	 	      }
	 	     layer.closeAll();
	 	     layer.msg("上传成功");
	 	      //上传成功
	 	      $("#goods_share_image").val(res.file_url);
	 		
	 	   },error: function(){
		      //演示失败状态，并实现重传
		      var demoText = $('#goods_share_image_demoText');
		      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
		      demoText.find('.demo-reload').on('click', function(){
		        uploadInst.upload();
		      });
		    }

	});
	
	
	

	 /* 分享单图  */
	 upload.render({
		    elem: '#wepro_qrcode_image_btn'
	 	   ,url: '<%=request.getContextPath()%>/uploadToQiNiu.do'
	 	   ,auto:true
	 	,size: 1024//限制文件大小，单位 KB
	 	   ,exts: 'jpg|png'
	 	   ,xhr:xhrOnProgress
	 	   ,progress:function(value){//上传进度回调 value进度值
	 	     console.log(value);
	 	     element.progress('demo', value+'%')//设置页面进度条
	 	    }
	 	   //,bindAction: '#test-upload-change-action'
	 	   ,before: function(obj){
	 	   //返回的参数item，即为当前的input DOM对象
	 	     layer.load(); //上传loading
	 	       console.log('文件上传中');
	 	 
	 	     //预读本地文件示例，不支持ie8
	 	     obj.preview(function(index, file, result){
	 	       $('#wepro_qrcode_image_demo').attr('src', result); //图片链接（base64）
	 	     });
	 	 
	 	   }
	 	   ,done: function(res){
	 	     console.log("返回码 : "+res.code);
	 		
	  		 //如果上传失败
	 	      if(res.code != 200){
	 	        return layer.msg('上传失败');
	 	      }
	 	     layer.closeAll();
	 	     layer.msg("上传成功");
	 	      //上传成功
	 	      $("#wepro_qrcode_image").val(res.file_url);
	 		
	 	   },error: function(){
		      //演示失败状态，并实现重传
		      var demoText = $('#wepro_qrcode_image_demoText');
		      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
		      demoText.find('.demo-reload').on('click', function(){
		        uploadInst.upload();
		      });
		    }

	});
	
	
	
});


$(document).on("mouseenter mouseleave", ".file-iteme", function(event){
    if(event.type === "mouseenter"){
        //鼠标悬浮
        $(this).children(".info").fadeIn("fast");
        $(this).children(".handle").fadeIn("fast");
    }else if(event.type === "mouseleave") {
        //鼠标离开
        $(this).children(".info").hide();
        $(this).children(".handle").hide();
    }
});

//删除图片
$(document).on("click", ".file-iteme .handle", function(event){
    
    var  $this = $(this).parent();   //  习惯性保存下当前标签
    var index = $this.index();
    console.info( index );
    
    
    $(this).parent().remove();
	  console.log(images);
  //获取下标
	//var subscript=$("#uploader-list img").index($(this));  
	//console.log("下标  :  "+subscript);
	//删除数组
	images.splice(index, 1);
	//重新排序
	//images.sort();
    console.log(images);
    
});


</script>   
<!-- 图片上传可视化用 -->
<script type="text/javascript">
//该部分代码主要使用ajax的xhr属性，我copy别人的，自己也不会写，应该不用管。

   var xhrOnProgress=function(fun) {
      xhrOnProgress.onprogress = fun; //绑定监听
       //使用闭包实现监听绑
      return function() {
          //通过$.ajaxSettings.xhr();获得XMLHttpRequest对象
          var xhr = $.ajaxSettings.xhr();
           //判断监听函数是否为函数
            if (typeof xhrOnProgress.onprogress !== 'function')
                 return xhr;
             //如果有监听函数并且xhr对象支持绑定时就把监听函数绑定上去
              if (xhrOnProgress.onprogress && xhr.upload) {
                    xhr.upload.onprogress = xhrOnProgress.onprogress;
              }
              return xhr;
       }
   };

// 图片弹出层
layui.use('layer', function(){
    $ = layui.jquery;//jquery
  layer = layui.layer;//弹出层

  //以上模块根据需要引入
	//轮播图弹出
    layer.ready(function(){ //为了layer.ext.js加载完毕再执行
      layer.photos({
        photos: '#x-img'
        //,shift: 5 //0-6的选择，指定弹出图片动画类型，默认随机
      });
    });

}); 
</script>  
<!-- ue初始化 -->
		<script type="text/javascript">
			var ue = UE.getEditor('editor',{
				autoFloatEnabled:true,//浮动
				toolbars: [[
		    		'source','bold', 'italic',  'removeformat', 'formatmatch', 'autotypeset','selectall', 'cleardoc', 
		           'lineheight', '|','fontfamily', 'fontsize', 'forecolor', 'backcolor','|',
		            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|','insertimage', 'emotion', 
		        ]]
			});
			
			/* var ue2 = UE.getEditor('editor_pz',{
				autoFloatEnabled:true,//浮动
				toolbars: [[
		    		'source','bold', 'italic',  'removeformat', 'formatmatch', 'autotypeset','selectall', 'cleardoc', 
		           'lineheight', '|','fontfamily', 'fontsize', 'forecolor', 'backcolor','|',
		            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|','insertimage', 'emotion', 
		        ]]
			}); */
			
		</script> 
			<!-- ue初始化 -->
		<script type="text/javascript">
			var ue = UE.getEditor('editor1',{
				toolbars: [[
		    		'source','bold', 'italic',  'removeformat', 'formatmatch', 'autotypeset','selectall', 'cleardoc', 
		           'lineheight', '|','fontfamily', 'fontsize', 'forecolor', 'backcolor','|',
		            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|','insertimage', 'emotion', 'insertvideo'
		        ]]
		    });
		</script>
  </body>
</html>